/**      
 * @file		cstrings.cpp
 * @description	This sample demonstrates how c++ copies cstrings.
 *				We can't use the assignment operator, =, to copy
 *				one string from another. We have to use strcpy() 
 *				from the cstring library
 * @course		CSCI 123 Section 00000
 * @assignment 
 * @date		mm/dd/yyyy
 * @author		Brad Rippe (00000000) brippe@fullcoll.edu
 * @version		1.0
 */
#include <iostream>
#include <cstring>
using namespace std;

/**
 * @return zero if the application executes successfully
 */
int main() {
	char cString1[] = "Please email my message to the class!";
	char cString2[] = "";

	cout << "This application demonstrates how to copy cstrings\n";
	cout << "Remember we can't use the assignment operator, = to assign";
	cout << " cstrings values unless we use it when we declare the cstring\n";
	cout << "Here is a sample of strcpy()\n";
	cout << "cString1 = " << cString1 << endl;
	cout << "cString2 = " << cString2 << endl;
	cout << "Now we'll use strcpy(destination, source) to copy cString1 to cString2\n";
	cout << "strcpy(cString2, cString1);\n";
	strcpy(cString2, cString1);
	cout << "cString1 = " << cString1 << endl;
	cout << "cString2 = " << cString2 << endl;
	// What happens with this code?
	// On my machine, both variables get allocated memory
	// cString2 only gets allocated enough memory for an empty string
	// cString1 is given the memory after cString2
	// when cString1 is copied to cString2, it overwrites part of 
	// cString1 this is bad

	return 0;
}

